package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.autoFile;
import com.sky.dto.DishPageQueryDTO;
import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealMapper {

    /**
     * 根据分类id查询套餐的数量
     * @param id
     * @return
     */
    @Select("select count(id) from setmeal where category_id = #{categoryId}")
    Integer countByCategoryId(Long id);

    // 分页查询


    Page<SetmealVO> pageQuery(SetmealPageQueryDTO setmealPageQueryDTO);


    @autoFile(value = OperationType.INSERT)
    //添加套餐的基本信息
    void save(Setmeal setmeal);

    //查询套餐的状态，判断是否可以删除
    Integer getStatusBiId(Long id);

    //删除套餐
    void delete(List<Long> ids);

    //根据id查询套餐的基本信息
    SetmealVO getSetmealById(Long id);

    //修改套餐基本信息
    @autoFile(value = OperationType.UPDATE)
    void updateSetmeal(Setmeal setmeal);

    //根据分类id查询套餐id查询套餐
    @Select("select * from setmeal where category_id = #{categoryId} and status = #{status}")
    List<Setmeal> getSetmealByCategoryId(Setmeal setmeal);


    //查询套餐总览
    Integer getSetmealCountByStatus(Integer disable);
}
